//
//  LPActivityDetailLivingDetailTableViewCell.m
//  LovingPartyBuilding
//
//  Created by 刘应平 on 2017/6/6.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "LPActivityDetailLivingDetailTableViewCell.h"

@interface LPActivityDetailLivingDetailTableViewCell ()
/**  ren  */
@property (strong, nonatomic) UILabel  *personLabel;
/**  iamgeVEIW  */
@property (strong, nonatomic) UIImageView  *lpImageView;
/**  label  */
@property (strong, nonatomic) UILabel  *lpContentLabel;
/**  时间  */
@property (strong, nonatomic) UILabel  *lpTimeLabel;
/**  下划线  */
@property (strong, nonatomic) UIView  *underLine;

@end
@implementation LPActivityDetailLivingDetailTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


/**  140  */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.underLine = [UIView new];
        self.underLine.backgroundColor = [UIColor themeGrayColor];
        [self addSubview:self.underLine];
        self.underLine.sd_layout.leftEqualToView(self).bottomEqualToView(self).widthIs([UIScreen zj_screenWith]).heightIs(1);
    }
    return self;
}




#pragma mark - 界面
- (void)layoutUI{
   
    [self addSubview:self.lpImageView];
    [self addSubview:self.lpTimeLabel];
    [self addSubview:self.personLabel];
    [self addSubview:self.lpContentLabel];
    
    
    self.lpImageView.sd_layout
    .topSpaceToView(self, 10 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self, 10 * [UIScreen zj_screenWScale])
    .widthIs([UIScreen zj_screenWith] / 2 - 30 * [UIScreen zj_screenWScale])
    .heightIs(120 * [UIScreen zj_screenHScale]);
    
    self.lpTimeLabel.sd_layout.bottomEqualToView(self.lpImageView)
    .leftSpaceToView(self.lpImageView, 10 * [UIScreen zj_screenWScale])
    .widthIs([UIScreen zj_screenWith] / 2 + 10 * [UIScreen zj_screenWScale])
    .heightIs(15 * [UIScreen zj_screenHScale]);
    
    self.personLabel.sd_layout
    .bottomSpaceToView(self.lpTimeLabel, 5 * [UIScreen zj_screenHScale])
    .leftEqualToView(self.lpTimeLabel)
    .rightEqualToView(self.lpTimeLabel)
    .heightIs(20 * [UIScreen zj_screenHScale]);

}

- (void)setModel:(LPActivityDetailLivingDetailModel *)model{
    _model = model;
    [self layoutUI];
    
    [self.lpImageView sd_setImageWithURL:[NSURL URLWithString:model.IMAGEPHOTO] placeholderImage:PlaceholderImage];
    self.lpTimeLabel.text = model.STARTTIME;
    self.personLabel.text = [NSString stringWithFormat:@"主讲人：%@",model.TEACHERSNAME];
    
    CGFloat height;
    if (model.HEIGHT < 82 * [UIScreen zj_screenHScale]) {
        height = model.HEIGHT;
    }else{
        height = 82 * [UIScreen zj_screenHScale];
    }
    
    self.lpContentLabel.sd_layout.topSpaceToView(self, 13 * [UIScreen zj_screenHScale])
    .leftSpaceToView(self.lpImageView, 10 * [UIScreen zj_screenWScale])
    .widthIs([UIScreen zj_screenWith] / 2 + 10 * [UIScreen zj_screenWScale])
    .heightIs(height);
    
    self.lpContentLabel.attributedText = [UILabel setSpaceForLineWithText:model.NAME lineSpace:3 * [UIScreen zj_screenHScale]];
}

- (void)setIsNoData:(BOOL)isNoData{
    _isNoData = isNoData;
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], 80 * [UIScreen zj_screenHScale])];
    label.font = [UIFont systemFontOfSize:16 * [UIScreen zj_textFontScale]];
    label.textColor = [UIColor textBlackColor];
    label.text = @"暂无直播";
    label.backgroundColor = [UIColor themeGrayColor];
    label.textAlignment = NSTextAlignmentCenter;
    [self addSubview:label];
}

- (void)setIsLastCell:(BOOL)isLastCell{
    _isLastCell = isLastCell;
    self.underLine.hidden = YES;
}

#pragma mark - getter
- (UILabel *)lpContentLabel{
    if (!_lpContentLabel) {
        _lpContentLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.numberOfLines = 0;
            label.textColor = [UIColor textBlackColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:16 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _lpContentLabel;
}


- (UILabel *)lpTimeLabel{
    if (!_lpTimeLabel) {
        _lpTimeLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor lightGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:15 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _lpTimeLabel;
}


- (UILabel *)personLabel{
    if (!_personLabel) {
        _personLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textGrayColor];
            label.backgroundColor = [UIColor clearColor];
            label.font = [UIFont systemFontOfSize:15 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _personLabel;
}
- (UIImageView *)lpImageView{
    if (!_lpImageView) {
        _lpImageView = [UIImageView new];
    }
    return _lpImageView;
}
@end
